<template>
  <div class="cameraBox_Box">
    <div class="accesscontrol_titleBox">
      <div class="titleBox1_l">
        <div class="Title_icon"></div>
        <span class="public_Text">摄像头名称</span>
      </div>
      <div class="titleBox1_r" @click="addClose"></div>
    </div>
    <div class="Video_box">
      <Flv :flvUrl="shexiangUrl" ref="FlvRef" />
    </div>
  </div>
</template>
<script setup>
import { ref, watch } from "vue"
import Flv from "@/components/Flv.vue"
import Flvlu from "@/components/Flvlu.vue"
const FlvRef = ref(null)

const emit = defineEmits(["closeCameraBox"])
const addClose = () => {
  emit("closeCameraBox")
  console.log(FlvRef.value)

  FlvRef.value.setdestroy()
}
const props = defineProps({
  shexiangObj: {
    type: Object,
    default: true
  }
})
const shexiangUrl = ref("")
const init = async (data) => {
  console.log(data)
  shexiangUrl.value = "/video/hls/stream.m3u8"
}
watch(
  () => props.shexiangObj,
  (val) => {
    console.log(val, "监听到了摄像头的变化")
    init(val)
  },
  {
    deep: true,
    immediate: true
  }
)
</script>
<style scoped lang="less">
.cameraBox_Box {
  width: 100%;
  height: 100%;
  background: url("@/assets/accessControl/shexiangtoditu.png") no-repeat center;
  background-size: 100% 100%;

  .accesscontrol_titleBox {
    width: 750px;
    height: 60px;
    position: absolute;
    left: 50%;
    top: 20px;
    transform: translate(-50%, 0);
    display: flex;
    align-items: center;
    justify-content: space-between;

    .titleBox1_l {
      width: 600px;
      height: 60px;
      display: flex;
      align-items: center;

      .Title_icon {
        margin-left: 20px;
        width: 50px;
        height: 50px;
        background: url("@/assets/accessControl/Vector.png") no-repeat center;
        background-size: 100% 100%;
      }

      span {
        margin-left: 20px;
      }
    }

    .titleBox1_r {
      cursor: pointer;
      width: 80px;
      height: 80px;
      background: url("@/assets/PatientInformation/xhao.png") no-repeat center;
      background-size: 100% 100%;
    }
  }

  .Video_box {
    width: 750px;
    height: 500px;
    position: absolute;
    left: 50%;
    top: 120px;
    transform: translate(-50%, 0);
    border-radius: 16px;
  }
}
</style>
